<!DOCTYPE html>
<html>
	<head id="title">
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<!--<title>医诺云检(业务端)</title>-->
		<title></title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/sale/index.css?time=20190314" />
		<script src="../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
	</style>
	<body>
		<div class="mui-content" id="index" v-cloak>
		  <nav class="mui-bar mui-bar-tab1">
				<a :class="{'mui-tab-item1':true,'mui-active1':active=='index'}" data-page="index">
					<span class="mui-icon iconfont icon-home"></span>
					<span class="mui-tab-label1">首页</span>
				</a>
				<a :class="{'mui-tab-item1':true,'mui-active':active=='pre'}" data-page="bespeak">
					<span class="mui-icon iconfont icon-leijiyuyue"><span class="mui-badge">{{num=='0'?'':num}}</span></span>
					<span class="mui-tab-label1">预约</span>
				</a>
				<a :class="{'mui-tab-item1':true,'mui-active':active=='mine'}" class="mui-tab-item" data-page="mine">
					<span class="mui-icon iconfont icon-wode">
						<!--<span class="mui-badge">2</span>-->
					</span>
					<span class="mui-tab-label1">我的</span>
				</a>
			</nav>
			<div id="tabbar" class="mui-control-content mui-active">
				<div class="showPanel">
			    	<div class="overflow panelTitle rel">
			    		<div class="left">
			    			<!--<img src="../../img/11.jpg" alt="avater" />-->
			    			<i class="iconfont icon-touxiang"></i>
			    			<span>{{saleData.name}}</span>
			    		</div>
			    		<div class="right abs">{{today}}</div>
			    	</div>
			    	<div class="overflow panelContainer">
			    		<div class="center">
			    			<div class="center num">{{saleData.amount}}</div>
			    			<div class="center todayCheck">今日检验金额(元)</div>
			    		</div>
			    	</div>
			    </div>
			    <div class="overflow panelContainer1">
			    		<div class="left">
			    			<div class="center num">{{saleData.actualAmount}}</div>
			    			<div class="center todayCheck">今日实收金额(元)</div>
			    		</div>
			    		<div class="right" @tap="todayOrder">
			    			<div class="center num">{{saleData.orderNumDay}}</div>
			    			<div class="center todayCheck">今日订单数</div>
			    		</div>
			    </div>
			    <div class="scan center">
			    	<div>快速查询:</div>
			    	<div><input type="text" placeholder="请扫描或输入条形码查询报告" v-model="inputCode" @focus="inputBarcode" @blur="outputBarcode" /></div>
			    	<div><span @tap="scanBarcode" :class="{'hidden':!isSearch}"><i class="iconfont icon-saomiao" ></i></span><span class="btn-primary" :class="{'hidden':isSearch}" @tap="search">查询</span></div>
			    </div>
			    <div class="workDesk">
			    	我的工作台
			    </div>
			    <ul class="mui-table-view mui-grid-view mui-grid-9">
					<li v-for="menu in menuList" v-show="tickets(menu.t,menu.n)" @tap="toDetail(menu.h)"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 orderTip">
					
						<a>
							<span class="mui-badge" v-if="orderTip>0&&menu.n=='订单'">{{orderTip}}</span>
							<span><img :src="menu.i"/></span>
							<!--<span><img src="../../img/single.png"/></span>-->
							<div class="mui-media-body">{{menu.n}}</div>
						</a>
					</li>
				<!-- 	<li @tap="toDetail('associatCode/noCodeList.html')"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
						<a>
					      <span><img src="../../img/single.png"/></span>
					      <div class="mui-media-body">关联条码</div>
						</a>
					</li> -->
			        <!--<li @tap="toDetail('../pay/saleOrder.html')"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/single.png"/></span>
				            <div class="mui-media-body">支付123</div>
			        	</a>
			        </li>
			        <li @tap="toDetail('../pay/saleOrder.html')"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/single.png"/></span>
				            <div class="mui-media-body">付款123</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('single/selectDoctor.html')"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/single.png"/></span>
				            <div class="mui-media-body">录单</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('payment/payment.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/payment.png"/></span>
				            <div class="mui-media-body">收款</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('pay/pay.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/pay.png"/></span>
				            <div class="mui-media-body">支付</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('order/order.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 orderTip">
			        	<a>
			        		<span class="mui-badge" v-if="orderTip>0">{{orderTip}}</span>
				            <span><img src="../../img/order.png"/></span>
				            <div class="mui-media-body">订单</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('statistics/statistics.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/statistics.png"/></span>
				            <div class="mui-media-body">统计</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('clinic/clinic.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/clinic.png"/></span>
				            <div class="mui-media-body">客户</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('inspectionCatalogue/catalogIndex.html?name=index')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 openBill">
			        	<a>
				            <span><img src="../../img/inspectionCatalogue.png"/></span>
				            <div class="mui-media-body">检测目录</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('replaceSingle/order.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 openBill">
			        	<a>
				            <span><img src="../../img/replaceSingle.png"/></span>
				            <div class="mui-media-body">代录单</div>
			        	</a>
			        </li>-->
			        <!--<li @tap="toDetail('materiel/materiel.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/materiel.png"/></span>
				            <div class="mui-media-body">物料</div>
			        	</a>
			        </li>-->
			    </ul> 
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<script src="../../js/vue.js"></script>
		<!-- <script src="js/cmms.js?timestamp='+new Date().getTime()+'" type="text/javascript" charset="utf-8"></script> -->
		<script src="../../js/cmms.js?time=333"></script>
		<script>
//			var title = new Vue({
//				el:"#title",
//				data:{
//					title:''
//				},
//				mounted(){
//					this.getTitle();
//				},
//				methods:{
//					getTitle(){
//						let _this = this;
//						AT.muiAjax('/passport/getLoginUser','post',{},function(res){
//							_this.title = res.partnerName;
//						});
//					}
//				}
//			});
			var index = new Vue({
				el:"#index",
				data:{
					today:'',
					active:'index',
					saleData:{},
					inputCode:'',//检验条形码
					num:0,
					isSearch:true,
					orderId:'',
					orderTip:0,
					menuList:[],
					title:'',
					userId:''
				
				},
				mounted(){
//					var vConsole = new VConsole();
					this.init();
					this.getIndexData();
					this.muiInit();
				},
				methods:{
					// 判断申请开票导航是否显示
					tickets(nt,ticName){

						if(nt==3 && ticName=="申请开票"){
							localStorage.setItem("tic",3)
						}
						return nt == 2?true:false
					},
					init(){
						let _this=this;
						/*接口配置*/
		    			AT.muiAjax('/partner-sale/partnerSale/wxConfig','post',
						{url:location.href.split('#')[0]},
						function(res){
							// console.log(res)
						
							wx.config({
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['scanQRCode']
							});
						});
					},
					getIndexData(){
						let _this = this;
						AT.muiAjax('/passport/getLoginUser','post',{},function(res){
							_this.menuList = res.menus;
							// console.log(_this.menuList);
							document.title = res.partnerName;
							localStorage.setItem('userId',res.userId);
						});
						AT.muiAjax('/partner-sale/appointment/getNum','post',{},function(res){
							// console.log(res);
							if(res>=10){
								_this.num = '9+';
							}else{
								_this.num = res;
							}
						});
						
						AT.muiAjax('/partner-sale/statistics/getHome','post',{},function(res){
							// console.log(res);
							_this.saleData = res;
							_this.today = res.getTime.split('T')[0];
							_this.userId = res.id;
						});
						//未确认订单数
						AT.muiAjax('/partner-sale/order/getCountUnConfirm','post',{},function(res){
							// console.log(res);
							_this.orderTip = res;
						});
						/*加载省市区*/
						AT.muiAjax('/common/common/selectRegionListTreeNew','post',{},
						function(res){
							console.log(res);
							let allArr = [];
							for(let i=0;i<res.length;i++){
								let subArr = [];
								let city = res[i].children;
								if(city){
//									console.log(city.length);
									for(let j=0;j<city.length;j++){
										let areaArr = [];
										let area1 = city[j].children;
										if(area1){
											for(let k=0;k<area1.length;k++){
												let litObj = {
													value:'',
													text:''
												}
												litObj.value = area1[k].id;
												litObj.text = area1[k].value;
												areaArr.push(litObj);
											}
										}
										let subObj = {
											value:'',
											text:'',
											children:[]
										}
										subObj.value = city[j].id;
										subObj.text = city[j].value;
										subObj.children = areaArr;
										subArr.push(subObj);
									}
								}	
//								console.log(subArr);
								let obj = {
									value:res[i].id,
									text:res[i].value,
									children:subArr
								}
								allArr.push(obj);
							}
//							this.cityData = allArr;
							localStorage.setItem('cityData',JSON.stringify(allArr));
//							console.log(this.cityData);
						});
					},
					muiInit(){
						let _this = this;
						mui(".mui-bar-tab1").on('tap','.mui-tab-item1',function(){
							let page = this.getAttribute('data-page');
							if(page=='bespeak'){
								location.href = "./bespeak/bespeak.html"
							}
							if(page=='mine'){
								location.href = "./mine/mine.html"
							}
						})
					},
					toDetail(url){
						// console.log(url)
						location.href = url;
					},
					todayOrder(){
						location.href="../sale/order/order.html?name=todayOrder";
					},
					getStatistics:function(){
						let _this = this;
					},
					tocheckDetail:function(){
						location.href = this.checkDetail;
					},
					search(){
						let _this = this;
						let reg=/^[A-Za-z0-9]{10,12}$/;
//						
						if(!reg.test(_this.inputCode)){
							mui.toast('条码必须为10~12位字母、数字!');
						}else{
							AT.muiAjax('/clinic-doctor/order/getOrderByServiceCode','post',{
								specimenBarCode:_this.inputCode
							},function(realData){
								// console.log(realData);
								/*代码存在跳转*/
								if(realData=="false"){
									mui.alert('该条码未存在，请重新输入!');
								}else{
									_this.orderId = realData;
									location.href = "./orderDetail.html?id="+_this.orderId+"&userId="+_this.userId;
								}
							});
						}
					},
					//输入10~12位服务码
					inputBarcode:function(){
						let _this = this;
						_this.isSearch = false;
					},
					outputBarcode:function(){
						let _this = this;
						_this.isSearch = true;
					},
					//扫描10~12位服务码
					scanBarcode:function(){
						let _this = this;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								let resultStr = res.resultStr.split(',');
								let scanbarCode = resultStr[resultStr.length-1]; 
								_this.inputCode = scanbarCode; 	
								AT.muiAjax('/clinic-doctor/order/getOrderByServiceCode','post',{
									specimenBarCode:_this.inputCode
								},function(realData){
									console.log(realData);
									/*代码存在跳转*/
									if(realData=="false"){
									mui.alert('该条码未存在，请重新输入!');
									}else{
										_this.orderId = realData;
										location.href = "./orderDetail.html?id="+_this.orderId;
									}
								});
							}
						});
					}
					
				}
			})
		</script>
	</body>
</html>